package hihocoder;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class 国庆出游2 {

	static class Vertex{
		public Vertex(int i) {
			this.index=i;
		}
		int index;
		boolean isVisted=false;
		ArrayList<Vertex> neibors=new ArrayList<>();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int T=scanner.nextInt();
		while (T-->0) {
			int n=scanner.nextInt();//城市数目
			HashMap<Integer,Vertex> set=new HashMap<>(n);//点的集合
			for(int i=0;i<n-1;i++){
				int a=scanner.nextInt();
				int b=scanner.nextInt();
				
				Vertex curVert,nextVert;
				if(set.containsKey(a)){
					curVert=set.get(a);
				}else {
					curVert=new Vertex(a);
					set.put(a, curVert);
				}
				if(set.containsKey(b)){
					nextVert=set.get(b);
				}else {
					nextVert=new Vertex(b);
					set.put(b, nextVert);
				}
				curVert.neibors.add(nextVert);
//				nextVert.neibors.add(curVert);//假设前一个都是父节点，后一个都是子节点
			}
			int m=scanner.nextInt();
			ArrayList<Integer> mArrayList=new ArrayList<>(m);
			while (m-->0) {
				mArrayList.add(scanner.nextInt());
			}
			Vertex firstVert=set.get(1);//出发点
			boolean flat=ableWithSeq(mArrayList,firstVert,set.values());
			if(flat){
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
	}
	private static boolean ableWithSeq(ArrayList<Integer> mArrayList, Vertex firstVert, Collection<Vertex> values) {
		ArrayList<Integer> thisList=new ArrayList<>();
		Stack<Vertex> visitedVertex=new Stack<>();
		visitedVertex.push(firstVert);
		while (!visitedVertex.isEmpty()) {
			Vertex vertex=visitedVertex.pop();
			if(mArrayList.contains(vertex.index)){
				thisList.add(vertex.index);
			}else {
				//访问左子还是右子是不确定的，可以互换的
				
			}
		}
		return false;
		
	}
	/***
	 * 
	 * @param index 父节点坐标
	 * @param childList
	 * @param mArrayList
	 * @return
	 */
	private static boolean isBefore(int index, ArrayList<Integer> childList, ArrayList<Integer> mArrayList) {
		int childIndex=0,mIndex=0;
		while (childList.get(childIndex)!=mArrayList.get(mIndex)&&mArrayList.get(mIndex)!=index) {
			mIndex++;
		}
		if(mArrayList.get(mIndex)!=index){
			return false;
		}else {
			return true;
		}
	}

}
